/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLL;

import DAL.ConnectUnit;
import DTO.Deposit_DTO;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;

/**
 *
 * @author Nguyen Phi Hung
 */
public class Deposit_BLL {
    ConnectUnit connection;
    
    public Deposit_BLL(){
        this.connection = DAL.DAL.getDAL();
    }
    public boolean Insert(String  procedure,Deposit_DTO info) throws Exception
    {
        CallableStatement cs=this.connection.GetCallableStatement(procedure);
        cs.setString(1,info.getBookID());
        cs.setString(2, info.getCustomerName());
        cs.setString(3, info.getIDNumber());
        cs.setDate(4, info.getDepositingDate());
        cs.setFloat(5, info.getAmountOfMoney());
        return cs.execute();
    }
    /*
     * kiểm tra số tiền gửi
     */
    public boolean KiemTraSoTienGui(String procedure,float SoTienGui) throws SQLException, Exception
    {
        CallableStatement  cs=this.connection.GetCallableStatement(procedure);
        cs.setFloat(1, SoTienGui);
        cs.registerOutParameter(2, java.sql.Types.BOOLEAN);
        cs.execute();
        return cs.getBoolean(2);
    }
    public static void main(String[]str) throws Exception
    {
        Deposit_BLL deposit_bll=new Deposit_BLL();
        Deposit_DTO info=new Deposit_DTO();
        info.setBookID("PS00000010");
        info.setCustomerName("sam");
        info.setIDNumber("122");
        info.setDepositingDate(null);
        info.setAmountOfMoney(1000000000);
        System.out.println(deposit_bll.KiemTraSoTienGui("{call KiemTra_SoTienGui(?,?)}", 199000));
    }
   
}
